use ActionStatus;
package ActionResult;

our $accesor = sub{
    my $obj = shift;
    my ($attrname, $newval) = (shift, shift);

    if(defined($attrname) && defined($newval)){
	$obj->{$attrname} = $newval;
    }

    return $obj->{$attrname} if(defined($attrname));
    return "";
};

sub new{
    my $class = shift;
    my $self = {};

    bless $self, $class;
    $self->init(@_);

    return $self;
}

sub init{
    my $self = shift;
    my ($status, $msg) = (shift, shift);

    $self->{STATUS} = ActionStatus->new($status);
    $self->{MESSAGE} = $msg;
}

sub is{
    my $self = shift;
    return $self->{STATUS}->is(shift);
}

sub status{
    my $self = shift;
    my $newStatusName = shift;

    my $newStatus;
    $newStatus = ActionStatus->new($newStatusName) if(defined($newStatusName));

    return &$accesor($self,"STATUS", $newStatus);
}

sub msg{
    my $self = shift;
    my $newMessage = shift;
    return &$accesor($self,"MESSAGE", $newMessage);
}

1;
